<template>
    <view class="dis_f_w_sb">
        <view v-for="(item,index) in goodsListData" :key="index" class="m_b_20 content_item" @click="handleToInfo(item)">
            <image src="@/static/img/xing.png" class="xing"></image>
            <image v-if="item.assistedBefore==0" src="@/static/img/ax.png" class="ax" @click.stop="handleHelp(item)"></image>
            <image v-else src="@/static/img/ax_check.png" class="ax"></image>
<!--            <image v-if="item.assistedBefore==0" :src="item.pictureUrl" style="width:100%;height: 500rpx;border-radius: 32rpx"></image>
            <image v-else :src="item.pictureUrl" style="width:100%;height: 450rpx;border-radius: 32rpx"></image>-->
            <image  :src="item.pictureUrl" style="width:300rpx;height: 350rpx;border-radius: 32rpx"></image>
            <view class="item_name">{{item.name}}</view>
            <view class="item_bf">
                <view class="p_5 dis_f_l_c" style="background-color: #FF5949;border-radius: 45rpx">
                    <image src="@/static/img/bf.png" style="width: 25rpx;height: 25rpx;"></image>
                    <view class="f_s_12 m_l_5"> {{item.helpMe||0}}</view>
                </view>
            </view>
        </view>
    </view>
</template>
<script>
import {addAssistedUserIdApi} from "@/sheep/api";

export default {
    name: "index",
    props: {
        goodsList: {
            type: Array,
            default: []
        },
        isLike: {
            type: Boolean,
            default: false
        },
        isReject: {
            type: Boolean,
            default: false
        },
        isRemove: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            goodsListData:this.goodsList||[],
        }
    },
    watch: {
        goodsList(curVal) {
            this.goodsListData=[]
            if (curVal.length>0){
                this.goodsListData = curVal
                for (let i = 0; i <curVal.length; i++) {
                    if (curVal[i].pictureUrl){
                        this.goodsListData[i].pictureUrl = curVal[i].pictureUrl.split(',')[0]
                    }
                }
            }
        }
    },
    methods:{
        handleToInfo(item){
            console.log("item", item);
            uni.navigateTo({
                url: '/pages/index/info?userId='+item.userId
            })
        },
        handleHelp(item){
            //二次确认
            let that = this
            uni.showModal({
                title: '提示',
                content: '确定帮助吗？',
                success: (res) => {
                    if (res.confirm) {
                        addAssistedUserIdApi({userId:item.userId}).then(res=>{
                            uni.showToast({
                                title: res.msg,
                                icon: "none",
                                duration: 2000
                            })
                            if (res.code==200){
                                that.$emit('updateData')
                            }
                        })
                    }
                }
            })

        },
        handleLike(item){
            this.$emit('handleLike',item)
        },
    }
}
</script>

<style scoped lang="scss">
.content_item{
    position: relative;
    width: 48%;
}
.item_name{
    position: absolute;
    z-index:99;
    bottom: 25rpx;
    left: 25rpx;
    color: #ffffff;
}
.item_bf{
    position: absolute;
    bottom: 0;
    right: 10rpx;
    color: #ffffff;
    background-color: #ffffff;
    border-radius: 45rpx;
    padding: 10rpx;
}
.ax{
    position: absolute;
    top: 15rpx;
    right: 40rpx;
    width: 70rpx;
    height: 70rpx;
    z-index: 99;
}
.xing{
    position: absolute;
    top: -26rpx;
    left: -24rpx;
    width: 50rpx;
    height: 50rpx;
    z-index: -1;
}
</style>
